package com.sita.tboard.global;

import com.sita.bike.rest.model.Account;
import com.sita.bike.utils.AccountUtils;
import com.sita.tboard.usermgmt.GetAccountInfoListener;
import com.sita.tboard.usermgmt.helper.UserNetworkHelper;

/**
 * Created by xiaodong on 16/3/8.
 */
public class AccountManager {
    private static class AccountManagerHolder {
        private static final AccountManager INSTANCE = new AccountManager();
    }

    private AccountManager() {
    }

    public static final AccountManager getInstance() {
        return AccountManagerHolder.INSTANCE;
    }

    private Account mAccount;

    public Account getAccount(){
        if (mAccount == null){
            UserNetworkHelper.getInstance().getUserInfo(AccountUtils.getAccountID(), new GetAccountInfoListener() {
                @Override
                public void onSuccess(Account account) {
                    mAccount = account;
                }

                @Override
                public void onFailure(Throwable throwable) {

                }
            });
        }
        return mAccount;
    }

    public void setAccount(Account account){
        mAccount = account;
    }
}
